home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / NUMBERS.SWG / 0004_BIT_ROT1.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  828b  |  26 lines

  1. The commands you need to rotate a Byte/Word are:
  2.  
  3. ROR, ROL, RCR, RCL.
  4. ROR ==> Rotates the bits the number of times specified, so that the
  5.         rightmost bits are rotated into the leftmost bits.  NO BITS
  6.         ARE LOST.  ROL is the same thing in the opposite direction.
  7.  
  8. RCR ==> Practically the same as the ROR/ROL instruction, but it rotates
  9.         the bit into the carry, and the carry bit is rotated into the
  10.         leftmost bit of the Byte/Word.  {Rotate right through carry}
  11.         RCL is the same in the other direction.
  12.  
  13. The format For each of ROR,ROL,RCR,RCL,SHR,SHL is
  14.  
  15.   [Instruction]  <Destination>  <Shift Count>
  16.  
  17. To reWrite your original code:
  18.  
  19. Asm
  20.   Mov  AL, ByteVar
  21.   Ror  AL, 1
  22.   Mov  ByteVar, AL
  23. end
  24.  
  25. The above would rotate the bits in the Variable ByteVar by one to the right.
  26.